<?php

namespace App\Services\IdentityOcr;

class IdentityOcrResult
{
    public bool $success;
    public string $message;
    public ?string $code;
    public array $data;
    public array $context;

    public function __construct(
        bool $success,
        string $message,
        ?string $code = null,
        array $data = [],
        array $context = []
    ) {
        $this->success = $success;
        $this->message = $message;
        $this->code = $code;
        $this->data = $data;
        $this->context = $context;
    }

    public static function success(array $data, string $message = '识别成功', array $context = []): self
    {
        return new self(true, $message, null, $data, $context);
    }

    public static function failure(string $message, ?string $code = null, array $context = []): self
    {
        return new self(false, $message, $code, [], $context);
    }
}
